﻿ using System;
   using System.Collections.Generic;
   using System.Linq;
  using System.Text;
   using Noodles.Core.Model;
    using NHibernate;
    using NHibernate.Criterion;

namespace Noodles.Core.Repositories
{
    public class PostRepository 
    {
        #region IRepository<Post> Members

        //void IRepository<Post>.Save(Post entity)
        //{
        //    using (ISession session = NHibernateHelper.OpenSession())
        //    {
        //        using (ITransaction transaction = session.BeginTransaction())
        //        {
        //            session.Save(entity);
        //            transaction.Commit();
        //        }
        //    }
        //}

        //void IRepository<Post>.Update(Post entity)
        //{
        //    using (ISession session = NHibernateHelper.OpenSession())
        //    {
        //        using (ITransaction transaction = session.BeginTransaction())
        //        {
        //            session.Update(entity);
        //            transaction.Commit();
        //        }
        //    }
        //}
        //void IRepository<Post>.Delete(Post entity)
        //{
        //    using (ISession session = NHibernateHelper.OpenSession())
        //    {
        //        using (ITransaction transaction = session.BeginTransaction())
        //        {
        //            session.Delete(entity);
        //            transaction.Commit();
        //        }
        //    }
        //}
        //Post IRepository<Post>.GetById(Guid id)
        //{
        //    using (ISession session = NHibernateHelper.OpenSession())
        //        return session.CreateCriteria<Post>().Add(Restrictions.Eq("Id", id)).UniqueResult<Post>();
        //}
        //IList<Post> IRepository<Post>.GetAll()
        //{
        //    using (ISession session = NHibernateHelper.OpenSession())
        //    {
        //        ICriteria criteria = session.CreateCriteria(typeof(Post));
        //        return criteria.List<Post>();
        //    }
        //}
        #endregion

    }
}